/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.kungkhies.persistence.entities;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.Lob;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author clayton
 */
@Entity 
@Table(name = "kungkhie_impl")
@XmlRootElement
@NamedQueries(
{
    @NamedQuery(name = "KungkhieImpl.findAll", query = "SELECT k FROM KungkhieImpl k"),
    @NamedQuery(name = "KungkhieImpl.findByKimplId", query = "SELECT k FROM KungkhieImpl k WHERE k.kimplId = :kimplId"),
    @NamedQuery(name = "KungkhieImpl.findByPublished", query = "SELECT k FROM KungkhieImpl k WHERE k.published = :published"),
    @NamedQuery(name = "KungkhieImpl.findByImplLastEdited", query = "SELECT k FROM KungkhieImpl k WHERE k.implLastEdited = :implLastEdited"),
    @NamedQuery(name = "KungkhieImpl.findByTimeEstimate", query = "SELECT k FROM KungkhieImpl k WHERE k.timeEstimate = :timeEstimate")
})
public class KungkhieImpl implements Serializable 
{
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "kimpl_id")
    private Long kimplId;
    @Basic(optional = false)
    @NotNull
    @Column(name = "published")
    @Temporal(TemporalType.TIMESTAMP)
    private Date published;
    @Basic(optional = false)
    @NotNull
    @Column(name = "impl_last_edited")
    @Temporal(TemporalType.TIMESTAMP)
    private Date implLastEdited;
    @Lob
    @Size(max = 65535)
    @Column(name = "comments")
    private String comments;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "time_estimate")
    private Float timeEstimate;
    @JoinTable(name = "kimpl_sweetie", joinColumns =
    {
        @JoinColumn(name = "kimpl_id", referencedColumnName = "kimpl_id")
    }, inverseJoinColumns =
    {
        @JoinColumn(name = "sweetie_id", referencedColumnName = "sweetie_id")
    })
    @ManyToMany
    private Collection<Sweetie> sweetieCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "kungkhieImpl")
    private Collection<ActivityAssessment> activityAssessmentCollection;
    @JoinColumn(name = "publisher_id", referencedColumnName = "kungkher_id")
    @ManyToOne(optional = false)
    private Kungkher publisherId;
    @JoinColumn(name = "kungkhie_id", referencedColumnName = "kungkhie_id")
    @ManyToOne(optional = false)
    private Kungkhie kungkhieId;

    public KungkhieImpl()
    {
    }

    public KungkhieImpl(Long kimplId)
    {
        this.kimplId = kimplId;
    }

    public KungkhieImpl(Long kimplId, Date published, Date implLastEdited)
    {
        this.kimplId = kimplId;
        this.published = published;
        this.implLastEdited = implLastEdited;
    }

    public Long getKimplId()
    {
        return kimplId;
    }

    public void setKimplId(Long kimplId)
    {
        this.kimplId = kimplId;
    }

    public Date getPublished()
    {
        return published;
    }

    public void setPublished(Date published)
    {
        this.published = published;
    }

    public Date getImplLastEdited()
    {
        return implLastEdited;
    }

    public void setImplLastEdited(Date implLastEdited)
    {
        this.implLastEdited = implLastEdited;
    }

    public String getComments()
    {
        return comments;
    }

    public void setComments(String comments)
    {
        this.comments = comments;
    }

    public Float getTimeEstimate()
    {
        return timeEstimate;
    }

    public void setTimeEstimate(Float timeEstimate)
    {
        this.timeEstimate = timeEstimate;
    }

    @XmlTransient
    public Collection<Sweetie> getSweetieCollection()
    {
        return sweetieCollection;
    }

    public void setSweetieCollection(Collection<Sweetie> sweetieCollection)
    {
        this.sweetieCollection = sweetieCollection;
    }

    @XmlTransient
    public Collection<ActivityAssessment> getActivityAssessmentCollection()
    {
        return activityAssessmentCollection;
    }

    public void setActivityAssessmentCollection(Collection<ActivityAssessment> activityAssessmentCollection)
    {
        this.activityAssessmentCollection = activityAssessmentCollection;
    }

    public Kungkher getPublisherId()
    {
        return publisherId;
    }

    public void setPublisherId(Kungkher publisherId)
    {
        this.publisherId = publisherId;
    }

    public Kungkhie getKungkhieId()
    {
        return kungkhieId;
    }

    public void setKungkhieId(Kungkhie kungkhieId)
    {
        this.kungkhieId = kungkhieId;
    }

    @Override
    public int hashCode()
    {
        int hash = 0;
        hash += (kimplId != null ? kimplId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object)
    {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof KungkhieImpl))
        {
            return false;
        }
        KungkhieImpl other = (KungkhieImpl) object;
        if ((this.kimplId == null && other.kimplId != null) || (this.kimplId != null && !this.kimplId.equals(other.kimplId)))
        {
            return false;
        }
        return true;
    }

    @Override
    public String toString()
    {
        return "com.kungkhies.persistence.entities.KungkhieImpl[ kimplId=" + kimplId + " ]";
    }

}
